<?php

require_once dirname(__FILE__).'/../lib/fotoGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/fotoGeneratorHelper.class.php';

/**
 * foto actions.
 *
 * @package    inmobiliaria
 * @subpackage foto
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class fotoActions extends autoFotoActions
{

  public function executeIndex(sfWebRequest $request)
  {

    $this->getUser()->setAttribute('idprop',$request->getParameter('propiedad_id') , 'admin_module');
    // sorting
    if ($request->getParameter('sort') && $this->isValidSortColumn($request->getParameter('sort')))
    {
      $this->setSort(array($request->getParameter('sort'), $request->getParameter('sort_type')));
    }

    // pager
    if ($request->getParameter('page'))
    {
      $this->setPage($request->getParameter('page'));
    }


    //parametro para filtrar las fotos
    if ($request->getParameter('propiedad_id'))
    {
      //$this->setPage($request->getParameter('page'));
        $propiedad_id=$request->getParameter('propiedad_id');
        $filters = $this->getFilters();
        $filters = array_merge($filters, array('propiedad_id' => $request->getParameter('propiedad_id')));
        $this->setFilters($filters);
        parent::executeIndex($request);

    }

    $this->pager = $this->getPager();
    $this->sort = $this->getSort();
  }

  public function executeNew(sfWebRequest $request)
  {


    //$this->fototemp = $this->getRoute()->getObject();
    $idprop=$this->getUser()->getAttribute('idprop',$request->getParameter('propiedad_id') , 'admin_module');
    $this->foto = new Foto();//$this->form->getObject();
    $this->foto->setPropiedadId($idprop);
    $this->form = $this->configuration->getForm($this->foto);
    //$this->foto = $this->getRoute()->;
    //$this->foto->setPropiedadId('2');
    //$this->form = $this->configuration->getForm($this->foto);
    //$this->foto->setPropiedadId($request->getParameter('propiedad_id'));
    //$this->form = $this->configuration->getForm($this->foto);
    //if ($request->getParameter('propiedad_id'))
    //{
      //$this->setPage($request->getParameter('page'));

        //$filters = $this->getFilters();
        //$filters = array_merge($filters, array('propiedad_id' => $request->getParameter('propiedad_id')));
        //$this->setFilters($filters);
        //parent::executeNew($request);

    //}

  }


}
